﻿using ServiceOperater.ViewModels;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows.Data;

namespace ServiceOperater.Converters
{
    // 右边Service,Action区域的ItemSource属性转换
    // 确保右侧的DataContext永远是ServiceTreeNodeViewModel
    public sealed class RightAreaDataContextConverter : IValueConverter
    {
        public static IValueConverter INSTANCE = new RightAreaDataContextConverter();

        public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
        {
            if (value is ActionTreeNodeViewModel)
            {
                return (value as ActionTreeNodeViewModel).Parent;
            }
            else
            {
                return (value as ServiceTreeNodeViewModel);
            }
        }

        public object ConvertBack(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
        {
            throw new NotImplementedException();
        }
    }
}
